<?php
require_once("../system/funciones_bd.php");
require_once("../system/sesion.class.php");
//Conexion base de datos local
$link = mysql_connect("localhost", "root", "");
$sesion = new sesion();
$usuario = $sesion->get("usuario");
if ($usuario == false) {
    header("Location: ../index.php");
} else {
    mysql_set_charset('utf8', $link);
    ?>
    <!DOCTYPE html>
    <html lang="de"><!-- use class="debug" here if you develope a template and want to check-->
        <head>
            <meta charset="UTF-8" />
            <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
            <!-- some meta tags, important for SEO"--> 
            <meta name="description" content="put a short description in here" />
            <meta name="keywords" content="put your important keywords in here" />
            <meta name="revisit-after" content="7 days" />
            <meta name="robots" content="index,follow" />

            <title>ForensicTooth v1.0</title>


            <link rel="stylesheet" href="../css/inuit.css" />
            <link rel="stylesheet" href="../css/fluid-grid16-1100px.css" />
            <link rel="stylesheet" href="../css/eve-styles.css" />
            <link rel="shortcut icon" href="../icon.png" />
            <link rel="apple-touch-icon-precomposed" href="../img/icon.png" />
            <link rel="stylesheet" href="../css/jquery-ui.css" />
            <script src="../js/jquery-1.9.1.js"></script>
            <script src="../js/jquery-ui.js"></script>            
            <script src="../js/respond-min.js" type="text/javascript"></script>
        </script>
        <script>
            $(function() {
                $("#dialog").dialog({
                    autoOpen: false,
                    modal: true
                });
                $(".abrir")
                        .button()
                        .click(function() {
                            $.ajax({
                                url: "actualizarGrupo.php?codigo=" + $(this).attr('codigo')
                            }).done(function(result) {
                                $("#dialog #contenido").html(result);
                            });
                            $("#dialog").dialog("open");
                        });
            });
        </script>
        <!--local fallback for JQuery-->

    </head>

    <!--===============================================================  Logo, social and menu =====================================================================================--> 
    <body>
        <div class="wrapper">	
            <a href="../index.php" id="logo"><img src="../img/logo.png" alt="something" />
                <h1 class="accessibility"></h1></a>
            <div class="social">
                <h2>
                    <?php echo $sesion->get("usuario"); ?> 
                </h2>
            </div>


            <ul id="nav" class="main">
                <li><a href="listaGrupoAdmin.php" class="active">Listas Grupos</a></li>
                <li><a href="principalAdmin.php">Regresar</a></li>
                <li><a href="../system/cerrarsesion.php">salir</a></li>
            </ul>

        </div><!--end of wrapper div--> 

        <div class="clear"></div>    
        <!--===============================================================  Intro =====================================================================================--> 
        <div class="wrapper">
            <div class="grids">
                <form>
                    <div style="text-align: right;"><a class="button" href="grupoAdmin.php" >Crear Grupo</a></div><br />
                    <table>
                        <thead>
                            <tr>
                                <th scope="col">CODIGO</th>
                                <th scope="col">DESCRIPCION</th>
                                <th scope="col">ACTIVO</th>
                                <th scope="col" width="10">Editar</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr><td colspan="5"></td></tr>
                        </tfoot>
                        <tbody>
                            <?php
                            mysql_set_charset('utf8', $link);
                            mysql_select_db("sirpof_db1", $link);
                            $resultRol = mysql_query("SELECT id_grupo, codigogrupo,descripciongrupo,activo FROM lista_grupo", $link);

                            $i = 0;
                            while ($rowRol = mysql_fetch_row($resultRol)) {
                                echo "<tr>
                                      <td>" . $rowRol[1] . "</td>
                                      <td>" . $rowRol[2] . "</td>
                                      <td>" . $rowRol[3] . "</td>
                                      <td><input id='abrir' type='button' class='button abrir' name='seleccion[$i]' value='Acturlizar' codigo ='" . $rowRol[0] . "'></td>
                                      </tr>\n";
                                $i++;
                            }
                            ?>
                        </tbody>                           
                    </table>

                </form>
                <div id="dialog" title="Datos Basicos">
                    <div id="contenido">
                        CARGANDO....
                    </div>
                </div>

            </div><!--end of div grids-->

        </div><!--end of div wrapper-->    

        <!--===============================================================  Footer =====================================================================================-->  
        <div class="wrapper">
            <div id="footer">


                <div class="grids">
                    <center>
                        <p>Sistema De Información ForensicTooth v 1.0</p>
                    </center>

                </div><!--end of grids-->
            </div><!--end of footer-->
        </div><!--end of wrapper-->



    </body>
    </html>

    <?php
}
?>